﻿//JumbotCms_4.1 Final
using System;
using System.Data;
using System.Web;
using Jumbot.Common;
using Jumbot.DataOper;
namespace JumbotCms.DataObject
{
    public class Thumb
    {
        private string m_Id = "0";
        private int m_ChannelId = 0;
        private string m_Title = string.Empty;
        private int m_iWidth = 0;
        private int m_iHeight = 0;

        public string Id
        {
            get { return m_Id; }
            set { m_Id = value; }
        }
        public int ChannelId
        {
            set { m_ChannelId = value; }
            get { return m_ChannelId; }
        }
        public string Title
        {
            set { m_Title = value; }
            get { return m_Title; }
        }
        public int iWidth
        {
            set { m_iWidth = value; }
            get { return m_iWidth; }
        }
        public int iHeight
        {
            set { m_iHeight = value; }
            get { return m_iHeight; }
        }

        public Thumb()
        {}
        public void GetAllColumn(string _id, DbOperHandler doh)
        {
            doh.Reset();
            doh.SqlCmd = "SELECT * FROM [jcms_normal_thumbs] WHERE [Id]=" + _id;
            DataTable dt = doh.GetDataTable();
            if (dt.Rows.Count > 0)
            {
                DataRow dr = dt.Rows[0];
                Id = _id;
                ChannelId = Validator.StrToInt(dr["ChannelId"].ToString(), 0);
                Title = dr["Title"].ToString();
                iWidth = Validator.StrToInt(dr["iWidth"].ToString(), 0);
                iHeight = Validator.StrToInt(dr["iHeight"].ToString(), 0);
            }
        }

        public int GetChannelId(string _id, DbOperHandler doh)
        {
            doh.Reset();
            doh.SqlCmd = "SELECT [ChannelId] FROM [jcms_normal_thumbs] WHERE [Id]=" + _id;
            DataTable dt = doh.GetDataTable();
            if (dt.Rows.Count > 0)
            {
                return Validator.StrToInt(dt.Rows[0]["ChannelId"].ToString(), 0);
            }
            return 0;
        }
        public string GetTitle(string _id, DbOperHandler doh)
        {
            doh.Reset();
            doh.SqlCmd = "SELECT [Title] FROM [jcms_normal_thumbs] WHERE [Id]=" + _id;
            DataTable dt = doh.GetDataTable();
            if (dt.Rows.Count > 0)
            {
                return dt.Rows[0]["Title"].ToString();
            }
            return string.Empty;
        }
        public int GetiWidth(string _id, DbOperHandler doh)
        {
            doh.Reset();
            doh.SqlCmd = "SELECT [iWidth] FROM [jcms_normal_thumbs] WHERE [Id]=" + _id;
            DataTable dt = doh.GetDataTable();
            if (dt.Rows.Count > 0)
            {
                return Validator.StrToInt(dt.Rows[0]["iWidth"].ToString(), 0);
            }
            return 0;
        }
        public int GetiHeight(string _id, DbOperHandler doh)
        {
            doh.Reset();
            doh.SqlCmd = "SELECT [iHeight] FROM [jcms_normal_thumbs] WHERE [Id]=" + _id;
            DataTable dt = doh.GetDataTable();
            if (dt.Rows.Count > 0)
            {
                return Validator.StrToInt(dt.Rows[0]["iHeight"].ToString(), 0);
            }
            return 0;
        }

    }
}
